package cn.fancylab.template.web.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.fancylab.model.acl.AuthUser;
import cn.fancylab.web.support.AclService;
import cn.fancylab.web.util.LoginUtils;

@Controller
public class LoginController extends AnnotationController {

	@Autowired
	@Qualifier("aclService")
	public AclService aclService;

	@RequestMapping("/login.xhtml")
	public String login(ModelMap model, String TARGETURL) {
		model.put("TARGETURL", TARGETURL);
		model.put("ptn", "user");

		String sessionId = LoginUtils.getSessid(getRequest());

		String username = (String) model.get("username");

		AuthUser authUser = aclService.loadUserByUsername(username);
		if (authUser != null) {

		}

		return "redirect:/manager/index.xhtml";
	}
}